package com.fp.helig.Res;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.ui.activity.BaseGameActivity;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

import android.content.Context;
import android.content.res.Resources;
import android.util.Log;




public class ObjectLoader {
	
	
	public PropertyList params;
	
	public void load(final BaseGameActivity activity,final Engine engine) throws URISyntaxException{
		
		Serializer serializer = new Persister();
	
		try {
			params = serializer.read(PropertyList.class,activity.getAssets().open("xml/objects.xml"));
			for (int i=0;i<params.gameObjects.size();i++)
			{
				params.gameObjects.get(i).LoadTexture(activity, engine);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//Log.v("NO FILE", "dsfsdf");
			e.printStackTrace();
		}
	}
	
	public int getIdByName(String name){
		
		for (int i=0;i<params.gameObjects.size();i++){
			if (params.gameObjects.get(i).mName.equals(name))
				return i;
		}
		return -1;
		
	}
		
}
